package cn.itcast.controller;

import cn.itcast.domain.company.Company;
import cn.itcast.service.company.CompanyService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CompanyController {

  @Reference
  private CompanyService companyService;

  /*
     url:/apply.do
     参数： Company 企业的对象
     返回： "1" 成功  "0" 失败
    */
  @RequestMapping("/apply")
  @ResponseBody
  public String apply(Company company) {
    try {
      //修改企业状态为0 ，没有审核
      company.setState(0);
      //保存企业
      companyService.save(company);
      return "1";
    } catch (Exception e) {
      e.printStackTrace();
      return "0";
    }
  }
}
